'''
Created on 2011-5-18

@author: lchengh2
'''
import unittest
import time
from myhomework.account.daos import *
from myhomework.homework.daos import *



class HomeworkDaoTestCase(unittest.TestCase):

    def test_add_homework_by_name(self):

        h1 = Homework(name='homework3',
                      content='content3',
                      deadline='2011-3-19',
                      type='personal')   
        HomeworkDao.add_homework(h1)
        h2 = Homework(name='homework4',
                      content='content4',
                      deadline='2011-7-19',
                      type='team')   
        HomeworkDao.add_homework(h2)
               
        h3 = Homework(name='homework4',
                      content='content4',
                      deadline='2011-6-19',
                      type='team')   
        self.assertRaises(HomeworkDuplicationError,HomeworkDao.add_homework,h3)
        self.assertRaises(HomeworkDuplicationError,HomeworkDao.add_homework,h2)      

    def test_get_homework_by_name(self):
        
        h1 = HomeworkDao.get_homework_by_name('homework3')
        self.assertEqual(h1.type,'personal')
        h2 = HomeworkDao.get_homework_by_name('homework4')
        self.assertEqual(h2.type,'team')
        
        self.assertRaises(HomeworkDoesNotExistError,HomeworkDao.get_homework_by_name,'homework5')
        
    def test_update_homework(self):
        h1 = HomeworkDao.get_homework_by_name('homework4')
        self.assertEqual(h1.type,'team')         
        h1.type = 'personal'
        HomeworkDao.update_homework(h1)
        self.assertEqual(h1.type,'personal') 
        h1.type = 'team'
        HomeworkDao.update_homework(h1)
        self.assertEqual(h1.type,'team')
        
        h2 = Homework(name='homework4',
                      content='content4',
                      deadline='2011-6-19',
                      type='team')
        self.assertRaises(HomeworkDoesNotExistError,HomeworkDao.update_homework,h2)
        h2.id = 100
        self.assertRaises(HomeworkDoesNotExistError,HomeworkDao.update_homework,h2)
        
    def test_delete_homework(self):
        
        self.assertEqual(HomeworkDao.get_homework_by_name('homework4').type,'team')        
        HomeworkDao.delete_homework_by_name('homework4')
        self.assertRaises(HomeworkDoesNotExistError,HomeworkDao.get_homework_by_name,'homewrok4')
        self.assertRaises(HomeworkDoesNotExistError,HomeworkDao.delete_homework_by_name,'homewrok7')
        
        h2 = Homework(name='homework4',
                      content='content4',
                      deadline='2011-7-19',
                      type='team')   
        HomeworkDao.add_homework(h2)        
                              
        
        
        
        
        
'''
Created on 2011-5-18

@author: lchengh2
'''


class  HomeworkSubmitedDaoCase(unittest.TestCase):

    def setUp(self):
        u1 = User(student_id='001', name='u1')
        UserDao.add_user(u1)
        u2 = User(student_id='002', name='u2')
        UserDao.add_user(u2)
        u3 = User(student_id='003', name='u3')
        UserDao.add_user(u3)
        u4 = User(student_id='004', name='u4')
        UserDao.add_user(u4)
        
        a_user = User.objects.get(student_id='001')
        b_user = User.objects.get(student_id='002')
        new_group = Group(administrator=a_user, name='g1')
        new_group.save()
        a_user.group = new_group
        b_user.group = new_group
        a_user.save()
        b_user.save()
 
        c_user = User.objects.get(student_id='003')
        d_user = User.objects.get(student_id='004')
        new_group2 = Group(administrator=c_user, name='g2')
        new_group2.save()
        c_user.group = new_group2
        d_user.group = new_group2
        c_user.save()
        d_user.save()       
        
        h1 = Homework(name='homework1',
                      content='content1',
                      deadline='2011-5-19',
                      type='personal')   
        HomeworkDao.add_homework(h1)
        h2 = Homework(name='homework2',
                      content='content2',
                      deadline='2011-6-19',
                      type='team')   
        HomeworkDao.add_homework(h2)

    def tearDown(self):
        
        HomeworkDao.delete_homework_by_name('homework1')
        HomeworkDao.delete_homework_by_name('homework2')
        for user in User.objects.all():
            user.auth_user.delete()
            user.delete()        
        
        for group in Group.objects.all():
            group.delete() 

    def test_homeworkd_submited(self):
        
        user1 = UserDao.get_user_by_student_id('001')
        user2 = UserDao.get_user_by_student_id('002')
        user3 = UserDao.get_user_by_student_id('003')
        group1 = GroupDao.get_group_by_name('g1')
        group2 = GroupDao.get_group_by_name('g2')
        p_homework = HomeworkDao.get_homework_by_name('homework1')
        t_homework = HomeworkDao.get_homework_by_name('homework2')
    
        '''
        test_add_homeworkd_submited
        '''    
        list = []
        c1 = Contribution(user=user1, contribution=30)
        c2 = Contribution(user=user2, contribution=70)
        list.append(c1)
        list.append(c2)
    
        homework_submited_info1 = HomeworkSubmitedInfo(homework=t_homework,
                                                          src='src1',
                                                          url='url1',
                                                          score=0,
                                                          rank =0)
        
        HomeworkSubmitedDao.add_homework_submited(homework_submited_info1, 
                                                  user1, 
                                                  list)
        
        homework_submited_info2 = HomeworkSubmitedInfo(homework=p_homework,
                                                          src='src1',
                                                          url='url1',
                                                          score=0,
                                                          rank =0)
                
        HomeworkSubmitedDao.add_homework_submited(homework_submited_info2, 
                                                  user1)
                
        self.assertRaises(HomeworkSubmitedInfoDuplicationError,
                          HomeworkSubmitedDao.add_homework_submited,
                          homework_submited_info1,
                          user1,
                          list)
        
        new_user = User(student_id='007', name='u1')
        
        self.assertRaises(UserIDNotExisted,
                          HomeworkSubmitedDao.add_homework_submited,
                          homework_submited_info1,
                          new_user,
                          list)
        
    
        '''
        test_get_homewrok_submited
        '''
        hs1 = HomeworkSubmitedDao.get_homework_submited(p_homework,user1)
        homework_submited_info1 = hs1.homework_submited_info
        self.assertEqual(homework_submited_info1.homework.name,'homework1')
        self.assertRaises(HomeworkSubmitedInfoDoesNotExistError,
                          HomeworkSubmitedDao.get_homework_submited,p_homework,user2) 
               
        hs2 = HomeworkSubmitedDao.get_homework_submited(t_homework,user2)
        homework_submited_info2 = hs2.homework_submited_info
        self.assertEqual(homework_submited_info2.homework.name,'homework2')
        
        hs3= HomeworkSubmitedDao.get_homework_submited(t_homework,user2)
        homework_submited_info3 = hs2.homework_submited_info               
        self.assertEqual(homework_submited_info3.homework.name,'homework2')
        
        self.assertRaises(HomeworkSubmitedInfoDoesNotExistError,
                          HomeworkSubmitedDao.get_homework_submited,t_homework,user3)
        self.assertEqual(HomeworkSubmitedDao.get_latest_homework_submited_of_individual(user3.student_id),[])                  
        
        homework_submited_info4 = HomeworkSubmitedInfo(homework=t_homework,
                                                          src='src3',
                                                          url='url3',
                                                          score=0,
                                                          rank =0)

        self.assertRaises(ContributionsIsNoneError,
                          HomeworkSubmitedDao.add_homework_submited,
                          homework_submited_info4,
                          user3)    
        
        '''
        test_get_latest_homework_submited_of_group
        '''       
        ps_hsi_0 = HomeworkSubmitedInfo(homework=p_homework,
                                      src='user1_src0',
                                      url='user1_url0',
                                      score=0,
                                      rank =0)
        HomeworkSubmitedDao.add_homework_submited(ps_hsi_0,user1)
        time.sleep(1)

        ps_hsi_1 = HomeworkSubmitedInfo(homework=p_homework,
                                      src='user1_src1',
                                      url='user1_url1',
                                      score=0,
                                      rank =0)  
        HomeworkSubmitedDao.add_homework_submited(ps_hsi_1,user1)
        
        ps_hsi_2 = HomeworkSubmitedInfo(homework=p_homework,
                                        src='user2_src0',
                                        url='user2_url0',
                                        score= 0,
                                        rank = 0)
        HomeworkSubmitedDao.add_homework_submited(ps_hsi_2,user2)
        time.sleep(1)

        ps_hsi_3 = HomeworkSubmitedInfo(homework=p_homework,
                                        src='user2_src1',
                                        url='user2_url1',
                                        score= 0,
                                        rank = 0)
        HomeworkSubmitedDao.add_homework_submited(ps_hsi_3,user2)
        
        
        
        list = []
        c1 = Contribution(user=user1, contribution=30)
        c2 = Contribution(user=user2, contribution=70)
        list.append(c1)
        list.append(c2)
        ts_hsi_1 = HomeworkSubmitedInfo(homework=t_homework,
                                        src='group1_src1',
                                        url='group1_url1',
                                        score= 0,
                                        rank = 0,
                                        )
        HomeworkSubmitedDao.add_homework_submited(ts_hsi_1,user1,list)
        time.sleep(1)

        ts_hsi_2 = HomeworkSubmitedInfo(homework=t_homework,
                                        src='group1_src2',
                                        url='group1_url2',
                                        score= 0,
                                        rank = 0)
        HomeworkSubmitedDao.add_homework_submited(ts_hsi_2,user1,list)       

        latest_phs_list = HomeworkSubmitedDao.get_latest_homework_submited_of_group(p_homework.id, 
                                                                                   group1.id)
        self.assertEqual(latest_phs_list[0].homework_submited_info.src,'user1_src1')
        self.assertEqual(latest_phs_list[1].homework_submited_info.src,'user2_src1')
        
        latest_ths_list = HomeworkSubmitedDao.get_latest_homework_submited_of_group(t_homework.id, 
                                                                                   group1.id)
        self.assertEqual(latest_ths_list[0].homework_submited_info.src,'group1_src2')  
        
        latest_ths_list = HomeworkSubmitedDao.get_latest_homework_submited_of_group(t_homework.id, 
                                                                                   group2.id)
        self.assertEqual(latest_ths_list,[])
        
        latest_phs_list = HomeworkSubmitedDao.get_latest_homework_submited_of_group(p_homework.id, 
                                                                                   group2.id)
        self.assertEqual(latest_phs_list,[])         
    
        user1_hs_list = HomeworkSubmitedDao.get_latest_homework_submited_of_individual(user1.student_id)
        self.assertEqual(user1_hs_list[0].homework_submited_info.src,'user1_src1')
        self.assertEqual(user1_hs_list[1].homework_submited_info.src,'group1_src2')

        user1_hs_list = HomeworkSubmitedDao.get_latest_homework_submited_of_individual(user3.student_id)
        self.assertEqual(user1_hs_list,[])       
    
        '''
        test_get_homework_submited_contributions
        '''
        contribution_list = HomeworkSubmitedDao.get_homework_submited_contributions(t_homework, 
                                                                                    group1)
        
        self.assertEqual(contribution_list[0].user,user1)
        self.assertEqual(contribution_list[0].contribution,30)
        self.assertEqual(contribution_list[1].user,user2)
        self.assertEqual(contribution_list[1].contribution,70)
        
        self.assertRaises(ContributionsDoesNotExistError,
                          HomeworkSubmitedDao.get_homework_submited_contributions,
                          t_homework,group2)
        self.assertRaises(ContributionsDoesNotExistError,
                          HomeworkSubmitedDao.get_homework_submited_contributions,
                          p_homework,group1)  
    
        '''
        test_update_homework_submited
        '''
        hs1 = HomeworkSubmitedDao.get_homework_submited(p_homework,user1)
        homework_submited_info1 = hs1.homework_submited_info
        homework_submited_info1.src = 'new_src'
        HomeworkSubmitedDao.update_homework_submited(homework_submited_info1)    
        self.assertEqual(homework_submited_info1.src,'new_src')
        homework_submited_info2 = HomeworkSubmitedInfo(homework=p_homework,
                                                          src='src3',
                                                          url='url3',
                                                          score= 0,
                                                          rank = 0)

        self.assertRaises(HomeworkSubmitedInfoDoesNotExistError,
                          HomeworkSubmitedDao.update_homework_submited,homework_submited_info2)
        homework_submited_info2.id = 100
        self.assertRaises(HomeworkSubmitedInfoDoesNotExistError,
                          HomeworkSubmitedDao.update_homework_submited,homework_submited_info2)        
        
        '''
        test_update_homework_submited_contributions
        '''
        contribution_list = HomeworkSubmitedDao.get_homework_submited_contributions(t_homework, 
                                                                                    group1)
        self.assertEqual(contribution_list[0].user,user1)
        self.assertEqual(contribution_list[0].contribution,30)
        self.assertEqual(contribution_list[1].user,user2)
        self.assertEqual(contribution_list[1].contribution,70)
        
        for c in contribution_list:
            c.contribution += 1
        HomeworkSubmitedDao.update_homework_submited_contributions(t_homework, group1, contribution_list)
        self.assertEqual(contribution_list[0].user,user1)
        self.assertEqual(contribution_list[0].contribution,31)
        self.assertEqual(contribution_list[1].user,user2)
        self.assertEqual(contribution_list[1].contribution,71)
        
        list = []
        c1 = Contribution(user=user1, contribution=80)
        c2 = Contribution(user=user2, contribution=20)
        list.append(c1)
        list.append(c2)
        HomeworkSubmitedDao.update_homework_submited_contributions(t_homework, group1, list)
        contribution_list = HomeworkSubmitedDao.get_homework_submited_contributions(t_homework, 
                                                                                    group1)
        self.assertEqual(contribution_list[0].user,user1)
        self.assertEqual(contribution_list[0].contribution,80)
        self.assertEqual(contribution_list[1].user,user2)
        self.assertEqual(contribution_list[1].contribution,20)
        
        self.assertRaises(ContributionsDoesNotExistError,
                          HomeworkSubmitedDao.update_homework_submited_contributions,
                          p_homework,group1,list)
        self.assertRaises(ContributionsDoesNotExistError,
                          HomeworkSubmitedDao.update_homework_submited_contributions,
                          t_homework,group2,list) 
        
        
        
        
        '''
        test_delete_homework_submited
        '''
        HomeworkSubmitedDao.delete_homework_submited(t_homework, group1.administrator)
        HomeworkSubmitedDao.delete_homework_submited(p_homework, user1)
        self.assertRaises(HomeworkSubmitedInfoDoesNotExistError,
                          HomeworkSubmitedDao.get_homework_submited,t_homework,group1.administrator)
        self.assertRaises(ContributionsDoesNotExistError,
                          HomeworkSubmitedDao.get_homework_submited_contributions,
                          t_homework,group1)
                                
        
'''
Created on 2011-5-14

@author: lchengh2
'''

class AssessmentDaoTestCase(unittest.TestCase):

    def setUp(self):
        u1 = User(student_id='001', name='u1')
        UserDao.add_user(u1)
        u2 = User(student_id='002', name='u2')
        UserDao.add_user(u2)
        u3 = User(student_id='003', name='u3')
        UserDao.add_user(u3)
        u4 = User(student_id='004', name='u4')
        UserDao.add_user(u4)
        u5 = User(student_id='005', name='u5')
        UserDao.add_user(u5)
        
        a_user = User.objects.get(student_id='001')
        b_user = User.objects.get(student_id='002')
        c_user = User.objects.get(student_id='005')
        new_group = Group(administrator=a_user, name='g1')
        new_group.save()
        a_user.group = new_group
        b_user.group = new_group
        c_user.group = new_group
        a_user.save()
        b_user.save()
        c_user.save()
 
        c_user = User.objects.get(student_id='003')
        d_user = User.objects.get(student_id='004')
        new_group2 = Group(administrator=c_user, name='g2')
        new_group2.save()
        c_user.group = new_group2
        d_user.group = new_group2
        c_user.save()
        d_user.save()       
        
        h1 = Homework(name='homework1',
                      content='content1',
                      deadline='2011-5-19',
                      type='personal')   
        HomeworkDao.add_homework(h1)
        h2 = Homework(name='homework2',
                      content='content2',
                      deadline='2011-6-19',
                      type='team')   
        HomeworkDao.add_homework(h2)
    
    def tearDown(self):
        HomeworkDao.delete_homework_by_name('homework1')
        HomeworkDao.delete_homework_by_name('homework2')
        for user in User.objects.all():
            user.auth_user.delete()
            user.delete()        
        
        for group in Group.objects.all():
            group.delete()        

    def test_assessment(self):
        
        
        user1 = UserDao.get_user_by_student_id('001')
        user2 = UserDao.get_user_by_student_id('002')
        user3 = UserDao.get_user_by_student_id('003')
        user4 = UserDao.get_user_by_student_id('004')
        user5 = UserDao.get_user_by_student_id('005')
        group1 = GroupDao.get_group_by_name('g1')
        group2 = GroupDao.get_group_by_name('g2')
        p_homework = HomeworkDao.get_homework_by_name('homework1')
        t_homework = HomeworkDao.get_homework_by_name('homework2')        
             
        '''
        submit homework
        '''
        list = []
        c1 = Contribution(user=user1, contribution=30)
        c2 = Contribution(user=user2, contribution=70)
        list.append(c1)
        list.append(c2)
    
        group1_ths1 = HomeworkSubmitedInfo(homework=t_homework,
                                    src='src1',
                                    url='url1',
                                    score=70,
                                    rank = 0)
        
        HomeworkSubmitedDao.add_homework_submited(group1_ths1, 
                                                  user1, 
                                                  list)
        
        user1_phs1 = HomeworkSubmitedInfo(homework=p_homework,
                                    src='src1',
                                    url='url1',
                                    score= 0,
                                    rank = 0)
                
        HomeworkSubmitedDao.add_homework_submited(user1_phs1, 
                                                  user1)

        user2_phs1 = HomeworkSubmitedInfo(homework=p_homework,
                                    src='src2',
                                    url='url2',
                                    score= 0,
                                    rank = 0)
                
        HomeworkSubmitedDao.add_homework_submited(user2_phs1, 
                                                  user2)  
        
        user5_phs1 = HomeworkSubmitedInfo(homework=p_homework,
                                    src='src5',
                                    url='url5',
                                    score= 0,
                                    rank = 0)
                
        HomeworkSubmitedDao.add_homework_submited(user5_phs1, 
                                                  user5)  
             
        '''
        assessment the homework
        '''  
        ranking_list = []
        ranking_list.append(user1.student_id)
        ranking_list.append(user2.student_id)
        ranking_list.append(user5.student_id)
        
        AssessmentDao.set_ranking_in_group(p_homework.id,
                                           group1.id,
                                           ranking_list)
        AssessmentDao.sumbmit_personal_homework_assessment(p_homework.id, 
                                                           group1.id, 
                                                           True, 
                                                           90, 
                                                           60)
        
        AssessmentDao.sumbmit_teamwork_assessment(t_homework.id, 
                                                  group1.id, 
                                                  85)
        
        am3 = Assessment(homework = t_homework,
                         group = group1,
                         highest_score = 75,
                         lowest_score = 70)
        self.assertRaises(AssessmentScoreValueError,AssessmentDao.add_assessment,am3)
        
        
        '''
        test get assessment
        '''
        new_am1 = AssessmentDao.get_assessment(p_homework.id, group1.id)
        self.assertEqual(new_am1.highest_score,90)
        self.assertEqual(new_am1.lowest_score,60)
        user1_phs1 = HomeworkSubmitedDao.get_homework_submited(p_homework, user1)
        user2_phs1 = HomeworkSubmitedDao.get_homework_submited(p_homework, user2)
        user5_phs1 = HomeworkSubmitedDao.get_homework_submited(p_homework, user5)
        self.assertEqual(user1_phs1.homework_submited_info.score, 99)    
        self.assertEqual(user2_phs1.homework_submited_info.score, 75)
        self.assertEqual(user5_phs1.homework_submited_info.score, 60)
        
        group1_ths1 = HomeworkSubmitedDao.get_homework_submited(t_homework, group1.administrator)
        self.assertEqual(group1_ths1.homework_submited_info.score, 85)
        
        rr = HomeworkSubmitedDao.get_latest_homework_submited_of_group(p_homework.id, group1.id)
        self.assertEqual(rr[0].homework_submited_info.ranking_in_group, 1)    
        self.assertEqual(rr[1].homework_submited_info.ranking_in_group, 2)
        self.assertEqual(rr[2].homework_submited_info.ranking_in_group, 3)
        
        '''
        update the assessment       
        '''
        new_am1.highest_score = 78
        new_am1.lowest_score = 60
        
        ranking_list2 = []
        ranking_list2.append(user5.student_id)
        ranking_list2.append(user2.student_id)
        ranking_list2.append(user1.student_id)
        AssessmentDao.set_ranking_in_group(p_homework.id, 
                                           group1.id, 
                                           ranking_list2)        
        
        AssessmentDao.update_assessment(new_am1)
        user1_phs1 = HomeworkSubmitedDao.get_homework_submited(p_homework, user1)
        user2_phs1 = HomeworkSubmitedDao.get_homework_submited(p_homework, user2)
        user5_phs1 = HomeworkSubmitedDao.get_homework_submited(p_homework, user5)
        self.assertEqual(user1_phs1.homework_submited_info.score, 68)    
        self.assertEqual(user2_phs1.homework_submited_info.score, 69)
        self.assertEqual(user5_phs1.homework_submited_info.score, 78)        

        '''
        test get homework performance
        '''
        user1_phs1_pfm = AssessmentDao.get_personal_homework_performance(p_homework.id, user1.student_id)
        self.assertEqual(user1_phs1_pfm['mark'],68)
        self.assertEqual(user1_phs1_pfm['rank'],3)
        
        group1_ths1_pfm = AssessmentDao.get_teamwork_performance(t_homework.id, group1.id)
        self.assertEqual(group1_ths1_pfm['mark'],85)
        self.assertEqual(group1_ths1_pfm['rank'],1)
        
        '''
        when ranking_check == 'False'
        '''
        new_am1.ranking_check = False
        AssessmentDao.update_assessment(new_am1)
        user1_phs1 = HomeworkSubmitedDao.get_homework_submited(p_homework, user1)
        user2_phs1 = HomeworkSubmitedDao.get_homework_submited(p_homework, user2)
        user5_phs1 = HomeworkSubmitedDao.get_homework_submited(p_homework, user5)
        self.assertEqual(user1_phs1.homework_submited_info.score, 54)    
        self.assertEqual(user2_phs1.homework_submited_info.score, 60)
        self.assertEqual(user5_phs1.homework_submited_info.score, 60)

        '''
        test get homework performance when ranking_check == 'False'
        '''
        user1_phs1_pfm = AssessmentDao.get_personal_homework_performance(p_homework.id, user1.student_id)
        self.assertEqual(user1_phs1_pfm['mark'],54)
        self.assertEqual(user1_phs1_pfm['rank'],2)
        
        '''
        test get_homework_performance
        '''
        result = AssessmentDao.get_homework_performance(p_homework.id,
                                                        user1.student_id)
        self.assertEqual(result['mark'],54)
        self.assertEqual(result['rank'],2)
        self.assertEqual(result['type'],'personal')                              
        
        result = AssessmentDao.get_homework_performance(t_homework.id,
                                                        user1.student_id)
        self.assertEqual(result['mark'],85)
        self.assertEqual(result['rank'],1)
        self.assertEqual(result['type'],'team')  
        
        result = AssessmentDao.get_homework_performance(t_homework.id,
                                                        user2.student_id)
        self.assertEqual(result['mark'],85)
        self.assertEqual(result['rank'],1)
        self.assertEqual(result['type'],'team') 
        
        result = AssessmentDao.get_homework_performance(t_homework.id,
                                                        user3.student_id)
        self.assertEqual(result,None)
        
        result = AssessmentDao.get_homework_performance(t_homework.id,
                                                        user4.student_id)
        self.assertEqual(result,None)     
        
        '''
        delete homework_submited_info of user5
        '''
        HomeworkSubmitedDao.delete_homework_submited(p_homework, user5)      
        new_am1.ranking_check = True
        AssessmentDao.update_assessment(new_am1)
        user1_phs1 = HomeworkSubmitedDao.get_homework_submited(p_homework, user1)
        user2_phs1 = HomeworkSubmitedDao.get_homework_submited(p_homework, user2)
        self.assertEqual(user1_phs1.homework_submited_info.score, 60)    
        self.assertEqual(user2_phs1.homework_submited_info.score, 78)               
        
        '''
        delete Assessment
        '''
        group1_am1 = AssessmentDao.get_assessment(p_homework.id, group1.id)
        AssessmentDao.delete_assessment(group1_am1)
        group1_am2 = AssessmentDao.get_assessment(t_homework.id, group1.id)
        AssessmentDao.delete_assessment(group1_am2)     
        self.assertRaises(AssessmentDoesNotExistError,AssessmentDao.get_assessment,
                          p_homework.id,
                          group1.id)
        self.assertRaises(AssessmentDoesNotExistError,AssessmentDao.get_assessment,
                          t_homework.id,
                          group1.id)
        user1_phs1 = HomeworkSubmitedDao.get_homework_submited(p_homework, user1)
        user2_phs1 = HomeworkSubmitedDao.get_homework_submited(p_homework, user2)
        self.assertEqual(user1_phs1.homework_submited_info.score, 0)    
        self.assertEqual(user2_phs1.homework_submited_info.score, 0)    

